<?php
error_reporting(E_ALL|E_STRICT);
date_default_timezone_set('Europe/London');


define('DEFAUL_URL','/calendar');
define('DEFAUL_LANGUAGE','ru');
define('LANGUAGES','ru,en');
define('ADMIN_EMAIL','vks0311@mail.ru');


try {
set_include_path('.' . PATH_SEPARATOR . './library/'
	 . PATH_SEPARATOR . './application/models/'
	 . PATH_SEPARATOR . './application/lib/'
	 . PATH_SEPARATOR . get_include_path());
include_once "Zend/Loader.php";
include_once 'Zend/Session.php';

Zend_Loader::loadClass('Zend_Controller_Front');
Zend_Loader::loadClass('Zend_Registry');
Zend_Loader::loadClass('Zend_View');
Zend_Loader::loadClass('Zend_Config_Ini');
Zend_Loader::loadClass('Zend_Db');
Zend_Loader::loadClass('Zend_Db_Table');
Zend_Loader::loadClass('Zend_Debug');
Zend_Loader::loadClass('Zend_Auth');

// load configuration
$config = new Zend_Config_Ini('./application/config.ini', 'general');
Zend_Registry::set('config', $config);

// setup database
$dbAdapter = Zend_Db::factory($config->db->adapter, 
        $config->db->config->toArray());
Zend_Db_Table::setDefaultAdapter($dbAdapter);
Zend_Registry::set('dbAdapter', $dbAdapter);

// setup controller
$frontController = Zend_Controller_Front::getInstance();
$frontController->throwExceptions(true);
$frontController->setControllerDirectory('./application/controllers');
$frontController->setDefaultControllerName('page');
$frontController->setParam('useDefaultControllerAlways', true);

$router = $frontController->getRouter();
$router->addRoute(
    'page',
    new Zend_Controller_Router_Route(
        'page/:article',
        array(
            'controller' => 'page',
            'action' => 'index'
        )
    )
);
$router->addRoute(
    'list',
    new Zend_Controller_Router_Route(
        'list/:alias',
        array(
            'controller' => 'page',
            'action' => 'list'
        )
    )
);
$router->addRoute(
    'test',
    new Zend_Controller_Router_Route(
        'test/:level',
        array(
            'controller' => 'test',
            'action' => 'index'
        )
    )
);
// run!
$frontController->dispatch();

} catch (Exception $e) {
    var_dump($e);
}